﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using yunbo.Model.PPMS;
using yunbo.Repositorys.PPMSRepositorys;

namespace yunbo.Controllers.PPMSControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class Mes_SCGDController : ControllerBase
    {
        Mes_SCGDRepository Mes_scgdRepository = new Mes_SCGDRepository();


        [HttpGet("GetMes_SCGD")]
        public IActionResult GetMes_SCGD()
        {
            List<Mes_SCGD> quans = Mes_scgdRepository.GetMes_SCGD();
            return Ok(quans);
        }            
        [HttpGet("GetMes_scjhcode")]
        public IActionResult GetMes_scjhcode(string scjh_code)
        {
            List<Mes_SCGD> quans = Mes_scgdRepository.GetMes_scjhcode(scjh_code);
            return Ok(quans);
        }

        [HttpPost("AddMes_SCGD")]
        public IActionResult AddMes_SCGD(ADDSCGD scgd)
        {
            var quans = Mes_scgdRepository.AddMes_SCGD(scgd);
            return Ok(quans);
        }
        [HttpGet("GetStatus")]
        public IActionResult GetStatus(string scjh_code)
        {
            var quans = Mes_scgdRepository.GetStatus(scjh_code);
            return Ok(quans);
        }

        [HttpPut("UpdateStatus")]
        public IActionResult UpdateStatus(string scgd_code, int state, int update_by, string scjh_code)
        {
            int quans = Mes_scgdRepository.UpdateStatus(scgd_code, state, update_by, scjh_code);
            return Ok(quans);
        }

        [HttpDelete("DeleteScgd")]
        public IActionResult DeleteScgd(string scgd_code)
        {
            var quans = Mes_scgdRepository.DeleteScgd(scgd_code);
            return Ok(quans);
        }

        [HttpPut("UpdateScgdJD")]
        public IActionResult UpdateScgdJD(int zt, int sl, int jd, string code)
        {
            bool rs = Mes_scgdRepository.UpdateScgdJD(zt,sl,jd,code)>0;
            return Ok(rs);
        }
        [HttpGet("GetGD")]
        public IActionResult GetGD(string code)
        {
            Mes_SCGD rs = Mes_scgdRepository.GetGD(code);
            return Ok(rs);
        }
    }
}
